1. Field of the Invention
The present invention relates to processors. More specifically, the present invention relates to methods and apparatus for accessing a memory on a processor.
2. Description of Related Art
Processors often store data and functions in different memories or in different parts of the same memory. The sizes of these memories may be different. In conventional processors, program and data memories are often implemented on a single device. However, in DSP processors, program and data memories are frequently implemented on separate devices with separate buses. Data memory is typically much faster and program memory is sometimes read only.
When parsing the source code written for such processors, a compiler must be able to recognize whether a pointer should be stored as a small or a large value (“near” or “far”). The compiler then generates the appropriate object code.
If the pointer variables used to store memory addresses cannot address the whole memory space, a programmer may decide to place a function in the directly addressable part of the memory space. This could be achieved, for example, by annotating the functions (or pointers to the functions) e.g., with explicit near/far declarations. This method requires extra programmer effort, both in initially labeling pointers and in re-labeling them if a function is relocated. Moreover, there is a danger that the programmer may fail to label a function correctly. For example, a “near” pointer may in fact end up requiring a large storage location.
Other systems have used the linker to detect all instances when the address of a program memory object is taken and to ensure that the object is stored as a small value so it can be handled by the code that is generated for data objects. Sometimes the linker inserts extra code so that only a stub of the program object is stored as a small value (i.e. a JUMP to the real memory location). This method consumes extra space and requires that at least some program memory be directly addressed.
It is therefore desirable to provide improved methods and apparatus for improving memory access efficiency.